python read json file

213

json dump to file -

import json

data = {"key": "value"}

with open('data.json', 'w') as jsonfile:
    json.dump(data, jsonfile)

open json file python -

import json

with open('data.txt') as json_file:
    data = json.load(json_file)

python read json file -

import json

with open('json_data.json') as json_file:
    data = json.load(json_file)
    print(data)

Comments

Submit
0 Comments